
/* dynamically load CSS files */
/*
$(document).ready(function() {

    loadCSS( "reset-css" , "../../includes/css/reset.css" );
    loadCSS( "slides-css" , "../../includes/css/slides.css" );
    
    function loadCSS( cssId , url )
    {
    	console.log( top != window );
    	
		//if (!document.getElementById(cssId))
		if ( top == window )
		{
			var head  = document.getElementsByTagName('head')[0];
			var link  = document.createElement('link');
			link.id   = cssId;
			link.rel  = 'stylesheet';
			link.type = 'text/css';
			link.href = url;
			link.media = 'screen';
			head.appendChild(link);
		}
	}
	
});
*/


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


$(document).ready(function() {
	if ( readCookie("hideaudio") ){
		$('.slide-control-toggle').addClass("slide-control-toggle-hidden");
		$('.slide-contol-content').hide();
	}

	var ap; // audio player
	var toggle; // audio player show/hide toggle

  	ap = document.getElementById('audioplayer');
    //ap.play();
    
    $('.slide-control-toggle').mousedown(function() {
    
	  $('.slide-control-content').slideToggle("fast" , function() {
	  	
	  	if ($('.slide-control-toggle').hasClass("slide-control-toggle-hidden"))
    	{
	  		$('.slide-control-toggle').removeClass("slide-control-toggle-hidden");
	  		eraseCookie("hideaudio");
	  	} else {
	  		$('.slide-control-toggle').addClass("slide-control-toggle-hidden");
	  		createCookie('hideaudio',true);
	  	}

	  });
	  
	});

});